﻿using Microsoft.AspNetCore.Mvc;
using ZhCun.WebUtils;
using ZhCun.WebUtils.Configs;
using ZhCun.WebUtils.DB;

namespace ZhCun.WebUtils
{
    public class BasePageUserController<TUserBLL> : BasePageController<TUserBLL>
        where TUserBLL : UserBaseBLL, new()
    {
        /// <summary>
        /// 登陆页面
        /// </summary>
        [UserPageAuthorize(false)]
        public IActionResult Login(string id)
        {
            ViewBag.AppCaption = CommonConfig.THIS.AppCaption;
            return View();
        }
        /// <summary>
        /// 安全退出，清除token
        /// </summary>
        public IActionResult LoginOut()
        {
            var token = HttpContext.GetToken();
            LoginState.Remove(token);
            HttpContext.DelCookieToken();
            return RedirectToAction("Login");
        }
        /// <summary>
        /// 用户信息修改
        /// </summary>
        public IActionResult Info()
        {
            var user = BLLObj.GetUserInfo();
            ViewBag.SaveUrl = "/api/apiuser/infosave";
            ViewBag.UserName = CurrUserName;
            ViewBag.MobileNumber = user.MobileNumber;
            return View();
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        public IActionResult Pwd()
        {
            ViewBag.SaveUrl = "/api/apiuser/pwdsave";
            return View();
        }
    }
}